#ifndef TESTPRINTING_H
#define TESTPRINTING_H

#include <QObject>
#include "payload.h"
#include <iostream>
#include "qslog.h"
#include "connectionerrorinfo.h"
#include "sessionstate.h"
#include "session.h"

using namespace apollo::core;

class TestPrinting : public QObject
{
	Q_OBJECT

public:
	TestPrinting(QObject *parent = NULL);
	~TestPrinting();
	public slots:
		void threadFinished()
		{
			QLOG_INFO() << "Quit event loop";
			QObject* s = sender(); 
			Session * session = dynamic_cast<Session*>(s);
			QLOG_INFO() << "Is Session? " << (session == NULL);
		}

		void printPayload(PayloadPtr payload)
		{
			QLOG_INFO()  << "message Id :" << payload->getMessageId();
			QLOG_INFO()  << "message Type :" << payload->getMessageType() ;
			QLOG_INFO()  << "header: " << payload->getHeader().toStdString() ;
			if(payload->getBodySize() > 0)
			{
				QLOG_INFO()  << "Body: " << payload->getMessage()->DebugString() ;
			}
		}

	
		void printError(const ConnectionErrorInfo& errorInfo)
		{
			QLOG_INFO()  << "Error Type :" << errorInfo.errorType
			 << ",Error Code :" << errorInfo.errorCode
			 << ",Desc: " << errorInfo.errorDesc ;
			
		}

		void printState(const SessionState& state)
		{
			QLOG_INFO()  << state.schema << state.ip << state.port << state.state;
			
			
		}

private:

};

#endif // TESTPRINTING_H
